#include "e300_config.h"
#include "system.h"

#define SCREEN_WIDTH  256
#define SCREEN_HEIGHT 32
#define TEXT_FONT "arial32.font"
#define NUM_FONT "ncoll32.font"


e300_config::e300_config()
{

}

void e300_config::start()
{
    creat_program_with_more_action();
//    creat_program();
}

QByteArray e300_config::creat_program()
{
    e300_program_t program;
    program.addr = 2;
    program.screen_width = SCREEN_WIDTH;
    program.screen_hight = SCREEN_HEIGHT;
    program.program_id = 2;
    program.ad_switch = 0;
    program.line_program_x = 0;
    program.line_progtam_y = 0;
    program.line_program_width = SCREEN_WIDTH;
    program.line_program_hight = SCREEN_HEIGHT;
    for(int i=0;i<8;i++)
        program.save[i] = 0;
    program.action_cnt = 1;
    for(int i=0;i<8;i++)
        program.priority_action[i] = 0;
    program.priority_action[0] = 9;

    QByteArray arry;
    arry.append((char*)&program, sizeof(e300_program_t));

    QString str = "program:";
    foreach (quint8 ch, arry) {
       str.append(QString("%1 ").arg(ch,2,16,QLatin1Char( '0' )));
    }
    DEBUG_INFO(str);

    QByteArray arry_buff = creat_action();
    arry.append( arry_buff);
//    DEBUG_INFO(QString("program_length:%1").arg(arry.length()));
    return arry;
}

QByteArray e300_config::creat_program_with_more_action()
{
    e300_program_t program;
    program.addr = 2;
    program.screen_width = SCREEN_WIDTH;
    program.screen_hight = SCREEN_HEIGHT;
    program.program_id = 2;
    program.ad_switch = 0;
    program.host_type = HOST_KAILUN;
    program.boad = 19200;
    program.line_program_x = 0;
    program.line_progtam_y = 0;
    program.line_program_width = SCREEN_WIDTH;
    program.line_program_hight = SCREEN_HEIGHT;
    for(int i=0;i<8;i++)
        program.save[i] = 0;
    program.action_cnt = 4;

    program.priority_action[0] = STOP_PROGRAM;
    program.priority_action[1] = LEFT_PROGRAM;
    program.priority_action[2] = RIGHT_PROGRAM;
    program.priority_action[3] = LINE_PROGRAM;
    program.priority_action[4] = HOST_AD_PROGRAM;
    program.priority_action[5] = HOST_AD_PROGRAM;
    program.priority_action[6] = HOST_AD_PROGRAM;
    program.priority_action[7] = HOST_AD_PROGRAM;

    QByteArray arry;
    arry.append((char*)&program, sizeof(e300_program_t));

    arry.append(creat_action());
    arry.append(creat_action_stop());
    arry.append(creat_action_left());
    arry.append(creat_action_right());
//    arry.append(creat_action_double());
//    DEBUG_INFO(QString("program_length:%1").arg(arry.length()));

//    QString str = "program:";
//    foreach (quint8 ch, arry) {
//       str.append(QString("%1 ").arg(ch,2,16,QLatin1Char( '0' )));
//    }
//    DEBUG_INFO(str);

    return arry;
}

QByteArray e300_config::creat_action()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = LINE_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 1;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = SCREEN_WIDTH;
    region.hight = SCREEN_HEIGHT;
    region.type = 1;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 3;//内部region个数


    e300_inside_region_t inside_region;//内部区域
    inside_region.min_width = 0;
    inside_region.max_width = 90;
    for(int i =0;i<8;i++)
    {
        inside_region.save[i] = 0;
    }
    inside_region.item_cnt = 1;//内部region中item个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0x00;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    item.text_font_length = sizeof (TEXT_FONT);
    item.other_font_length = sizeof (NUM_FONT);
    item.text_font.append(TEXT_FONT);
    item.other_font.append(NUM_FONT);
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_left;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
    QString text = "%line_num%";

    QByteArray arry_buff = creat_inside_region(inside_region,item,text);
//    QByteArray arry_buff;

    inside_region.min_width = SCREEN_HEIGHT;
    inside_region.max_width = SCREEN_HEIGHT;


    item.message_type = 2;
    text = "right.bin";
    item.move_type = MOVE_RIGHT_CONTINUE;
    arry_buff.append(creat_inside_region(inside_region,item,text));

    inside_region.min_width = 0;
    inside_region.max_width = SCREEN_WIDTH;
    item.message_type = 1;
    text = "%end_station1%";
    item.move_type = MOVE_LEFT;
    arry_buff.append(creat_inside_region(inside_region,item,text));

    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + region.length + 2;
    arry.append((char*)&action, sizeof(action));
    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::creat_action_left()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = LEFT_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 2;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = SCREEN_HEIGHT;
    region.hight = SCREEN_HEIGHT;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0x00;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    item.text_font_length = sizeof (TEXT_FONT);
    item.other_font_length = sizeof (NUM_FONT);
    item.text_font.append(TEXT_FONT);
    item.other_font.append(NUM_FONT);
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 2;
    QString text = "left.bin";
    item.move_type = MOVE_LEFT_CONTINUE;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);

    region.x = SCREEN_HEIGHT;
    region.y = 0;
    region.width = SCREEN_WIDTH - SCREEN_HEIGHT;
    region.hight = SCREEN_HEIGHT;


    item.message_type = 1;
    text = "%line_num%";
    item.move_type = MOVE_LEFT;
    arry_buff.append(creat_region(region,item,text));

//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::creat_action_right()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = RIGHT_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 2;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = SCREEN_WIDTH - SCREEN_HEIGHT;
    region.y = 0;
    region.width = SCREEN_HEIGHT;
    region.hight = SCREEN_HEIGHT;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0x00;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    item.text_font_length = sizeof (TEXT_FONT);
    item.other_font_length = sizeof (NUM_FONT);
    item.text_font.append(TEXT_FONT);
    item.other_font.append(NUM_FONT);
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 2;
    QString text = "right.bin";
    item.move_type = MOVE_LEFT_CONTINUE;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);

    region.x = 0;
    region.y = 0;
    region.width = SCREEN_WIDTH - SCREEN_HEIGHT;
    region.hight = SCREEN_HEIGHT;


    item.message_type = 1;
    text = "%line_num%";
    item.move_type = MOVE_LEFT;
    arry_buff.append(creat_region(region,item,text));

//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::creat_action_stop()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = STOP_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 1;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = SCREEN_WIDTH;
    region.hight = SCREEN_HEIGHT;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0x00;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    item.text_font_length = sizeof (TEXT_FONT);
    item.other_font_length = sizeof (NUM_FONT);
    item.text_font.append(TEXT_FONT);
    item.other_font.append(NUM_FONT);
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


//    item.message_type = 2;
//     QString text = "right_2.bin";
//    item.move_type = MOVE_LEFT_CONTINUE;
    QByteArray arry_buff;
//    QByteArray arry_buff = creat_region(region,item,text);

//    region.x = 0;
//    region.y = 0;
//    region.width = 128;
//    region.hight = 32;


    item.message_type = 1;
    QString text = "%line_num%";
    item.move_type = MOVE_LEFT;
    arry_buff.append(creat_region(region,item,text));

//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    DEBUG_INFO(QString("action len:%1,region len:%2").arg(action.lenght).arg(region.length));
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);

    QString str = "stop region:";
    foreach (quint8 ch, arry_buff) {
       str.append(QString("%1 ").arg(ch,2,16,QLatin1Char( '0' )));
    }
    DEBUG_INFO(str);
    return arry;
}

QByteArray e300_config::creat_action_double()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = RIGHT_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 2;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = SCREEN_WIDTH - SCREEN_HEIGHT;
    region.y = 0;
    region.width = SCREEN_HEIGHT;
    region.hight = SCREEN_HEIGHT;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0x00;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    item.text_font_length = sizeof (TEXT_FONT);
    item.other_font_length = sizeof (NUM_FONT);
    item.text_font.append(TEXT_FONT);
    item.other_font.append(NUM_FONT);
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 2;
    QString text = "right.bin";
    item.move_type = MOVE_LEFT_CONTINUE;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);

    region.x = 0;
    region.y = 0;
    region.width = SCREEN_WIDTH - SCREEN_HEIGHT;
    region.hight = SCREEN_HEIGHT;


    item.message_type = 1;
    text = "%line_num%";
    item.move_type = MOVE_LEFT;
    arry_buff.append(creat_region(region,item,text));

//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}


/*
 * 创建静态区域
*/
QByteArray e300_config::creat_region(e300_region_t region,e300_item_t item,QString text)
{
//    e300_region_t region;
//    region.length = 0;
//    region.x = 0;
//    region.y = 0;
//    region.width = 160;
//    region.hight = 32;
//    region.type = 0;
//    for(int i =0;i<8;i++)
//    {
//        region.save[i] = 0;
//    }
//    region.region_cnt = 1;

    QByteArray arry;
    QByteArray arry_buff = creat_item(item,text);
    region.length = sizeof (e300_region_t) -2 + arry_buff.length();

    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);

//    QString str = "item:";
//    foreach (quint8 ch, arry) {
//       str.append(QString("%1 ").arg(ch,2,16,QLatin1Char( '0' )));
//    }
//    DEBUG_INFO(str);

    return arry;
}

/*
 * 创建动态区域
*/
QByteArray e300_config::creat_inside_region(e300_inside_region_t region, e300_item_t item, QString text)
{
    QByteArray arry;
    QByteArray arry_buff = creat_item(item,text);
    region.length = sizeof (e300_inside_region_t) -2 + arry_buff.length();

    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);

    return arry;
}

QByteArray e300_config::creat_item(e300_item_t item,QString text)
{
//    e300_item_t item;

//    item.effect = 18;
//    item.exit = 1;
//    item.message_type = 1;
//    item.x_move = 0;
//    item.text_color[0] = 0xff;
//    item.text_color[1] = 0x00;
//    item.text_color[2] = 0x00;
//    item.backcolor[0] = 0x00;
//    item.backcolor[1] = 0x00;
//    item.backcolor[2] = 0x00;
//    strcpy(item.text_font,"arial32");
//    strcpy(item.other_font,"ncoll32");
//    item.bold = 0;
//    item.text_size = 32;
//    item.other_size = 32;
//    item.play_time = 0;
//    item.speed = 24;
//    item.font_gap = 0;
//    item.shui_ping_type = 0;
//    item.chui_zhi_type = 0;
//    for(int i =0;i<8;i++)
//    {
//        item.save[i] = 0;
//    }
//    QString text = "%%0";


    QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf-8"));
    QTextCodec *gbk = QTextCodec::codecForName("GB18030");
    QTextCodec *utf8 = QTextCodec::codecForName("UTF-8");

    QString strUnicode;
    strUnicode = utf8->toUnicode(text.toLocal8Bit().data());
    QByteArray text_data = gbk->fromUnicode(strUnicode);

    item.text_length = text_data.length();

    item.item_length = sizeof (e300_item_t) - 2 + text_data.length();

    QByteArray arry;

    arry.append(item.item_length >> 8);
     arry.append(item.item_length & 0xff);
    arry.append(item.effect);
    arry.append(item.exit);
    arry.append(item.message_type);


    arry.append(item.x_move);
    arry.append(item.text_color[0]);
    arry.append(item.text_color[1]);
    arry.append(item.text_color[2]);
    arry.append(item.backcolor[0]);
    arry.append(item.backcolor[1]);
    arry.append(item.backcolor[2]);
    arry.append(item.text_font_length);
//    char text_font[20];
   arry.append(item.text_font);
   arry.append(item.other_font_length);
//    char other_font[20];
    arry.append(item.other_font);
   arry.append(item.bold);
   arry.append(item.text_size);
   arry.append(item.other_size);
    arry.append(item.play_time);
   arry.append(item.speed & 0xff);
   arry.append(item.speed >> 8);
    arry.append(item.font_gap);
    arry.append(item.shui_ping_type);
    arry.append(item.chui_zhi_type);
    arry.append(item.move_type);
    arry.append(item.save[0]);
    arry.append(item.save[1]);
    arry.append(item.save[2]);
    arry.append(item.save[3]);
    arry.append(item.save[4]);
    arry.append(item.save[5]);
    arry.append(item.save[6]);
    arry.append(item.save[7]);
    arry.append(item.id);
    arry.append(item.text_length& 0xff);
    arry.append(item.text_length >> 8);
    arry.append(text_data);
    item.item_length = arry.length() - 2;
    arry[0] = item.item_length & 0xff;
    arry[1] = item.item_length >> 8;
//    QString str = "arry:";
//    foreach (quint8 ch, arry) {
//       str.append(QString("%1 ").arg(ch,2,16,QLatin1Char( '0' )));
//    }
//    DEBUG_INFO(str);

    return arry;

}

QByteArray e300_config::get_illegal_words(QString file_patch)
{
    QByteArray arry;
    QByteArray arry_buff;
    QFile file;
    file.setFileName(file_patch);

    if(!file.open(QIODevice::ReadOnly))
    {
        DEBUG_ERROR("file open error");
        return arry;
    }

    arry_buff = file.readAll();
    file.close();

    QJsonParseError error;
    QJsonDocument doc = QJsonDocument::fromJson(arry_buff,&error);

    if(error.error != QJsonParseError::NoError)
    {
        DEBUG_ERROR(QString("%1").arg(error.error));
        DEBUG_ERROR("file change to json error");
        return arry;
    }

    QVariantMap root = doc.toVariant().toMap();

    QVariantList temp_list = root.value("illegal_words").toList();

    quint16 cnt = 0;
    arry.append(cnt & 0xff);
    arry.append(cnt >> 8);
    foreach(QVariant var,temp_list)
    {
        QString text = var.toString();
        DEBUG_INFO(text);
        QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf-8"));
        QTextCodec *gbk = QTextCodec::codecForName("GB18030");
        QTextCodec *utf8 = QTextCodec::codecForName("UTF-8");

        QString strUnicode;
        strUnicode = utf8->toUnicode(text.toLocal8Bit().data());
        QByteArray key_arry = gbk->fromUnicode(strUnicode);

        arry.append(key_arry.length());
        arry.append(key_arry);
        cnt++;
    }
    arry[0] =  cnt & 0xff;
    arry[1] = cnt >> 8;

    return arry;
}


QByteArray e300_config::xin_hong_creat_program_qian()
{
    e300_program_t program;
    program.addr = xin_hong_qian_pai_addr;
    program.screen_width = SCREEN_WIDTH;
    program.screen_hight = SCREEN_HEIGHT;
    program.program_id = 2;
    program.ad_switch = 0;
    program.host_type = HOST_HISSEN;
    program.boad = 38400;
    program.line_program_x = 0;
    program.line_progtam_y = 0;
    program.line_program_width = SCREEN_WIDTH;
    program.line_program_hight = SCREEN_HEIGHT;
    for(int i=0;i<8;i++)
        program.save[i] = 0;
    program.action_cnt = 2;

    program.priority_action[0] = STOP_PROGRAM;
    program.priority_action[1] = DOUBLE_PROGRAM;
    program.priority_action[2] = LEFT_PROGRAM;
    program.priority_action[3] = RIGHT_PROGRAM;
    program.priority_action[4] = LINE_PROGRAM;
    program.priority_action[5] = NO_WORK_PROGRAM;
    program.priority_action[6] = HOST_AD_PROGRAM;
    program.priority_action[7] = HOST_AD_PROGRAM;

    QByteArray arry;
    arry.append((char*)&program, sizeof(e300_program_t));

    arry.append(xin_hong_creat_action_2());
    arry.append(xin_hong_creat_action_noWork());
//    arry.append(xin_hong_creat_action_stop());
//    arry.append(xin_hong_creat_action_left());
//    arry.append(xin_hong_creat_action_right());
//    arry.append(creat_action_double());
//    DEBUG_INFO(QString("program_length:%1").arg(arry.length()));

//    QString str = "program:";
//    foreach (quint8 ch, arry) {
//       str.append(QString("%1 ").arg(ch,2,16,QLatin1Char( '0' )));
//    }
//    DEBUG_INFO(str);

    return arry;
}


/*
 * 屏幕尺寸：160x16
 * 默认节目单、静态区域：  起点 线路 终点
 * 颜色分布：黄 + 红 + 黄
 * 区域布局：4 2 4
*/
QByteArray e300_config::xin_hong_creat_action()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = LINE_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 1;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = SCREEN_WIDTH;
    region.hight = SCREEN_HEIGHT;
    region.type = 1;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 3;//内部region个数


    e300_inside_region_t inside_region;//内部区域
    inside_region.min_width = 0;
    inside_region.max_width = 60;
    for(int i =0;i<8;i++)
    {
        inside_region.save[i] = 0;
    }
    inside_region.item_cnt = 1;//内部region中item个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0xFF;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    item.text_font_length = sizeof (TEXT_FONT);
    item.other_font_length = sizeof (NUM_FONT);
    item.text_font.append(TEXT_FONT);
    item.other_font.append(NUM_FONT);
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_left;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
    QString text = "%start_station1%";

    QByteArray arry_buff = creat_inside_region(inside_region,item,text);
//    QByteArray arry_buff;


    item.text_color[0] = 0xff;
    item.text_color[1] = 0x00;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    inside_region.min_width = 0;
    inside_region.max_width = 40;
    item.message_type = 1;
    text = "%line_num%";
    item.move_type = MOVE_LEFT;
    arry_buff.append(creat_inside_region(inside_region,item,text));


    item.text_color[0] = 0xff;
    item.text_color[1] = 0xFF;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    inside_region.min_width = 0;
    inside_region.max_width = SCREEN_WIDTH;
    item.message_type = 1;
    text = "%end_station1%";
    item.move_type = MOVE_LEFT;
    arry_buff.append(creat_inside_region(inside_region,item,text));

    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + region.length + 2;
    arry.append((char*)&action, sizeof(action));
    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

/*
 * 静态区域：  起点+线路+终点
 * 区域宽度划分：64+32+64
 * 颜色：黄+红+黄
*/

QByteArray e300_config::xin_hong_creat_action_2()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = LINE_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 4;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 32;
    region.y = 0;
    region.width = 64;
    region.hight = SCREEN_HEIGHT;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0xff;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;


    QString text_font = TEXT_FONT;
    QString other_font = NUM_FONT;
    item.text_font_length = text_font.length();
    item.other_font_length = other_font.length();
    item.text_font.append(text_font.toUtf8());
    item.other_font.append(other_font.toUtf8());
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 1;
    item.id = 1;
    QString text = "%line_num%";
    item.move_type = MOVE_LEFT;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);


    region.x = 0;
    region.y = 0;
    region.width = 32;
    region.hight = SCREEN_HEIGHT;

    item.message_type = 2;
    text = "bell.bin";
    item.move_type = MOVE_STATIC;
    arry_buff.append(creat_region(region,item,text));

    region.x = 96;
    region.y = 0;
    region.width = 32;
    region.hight = 32;

    item.message_type = 2;
    text = "head_arrow.bin";
    item.move_type = MOVE_STATIC;
    arry_buff.append(creat_region(region,item,text));

    region.x = 128;
    region.y = 0;
    region.width = 128;
    region.hight = SCREEN_HEIGHT;
    item.id = 3;
    item.message_type = 1;
    text = "%end_station1%";
    item.move_type = MOVE_STATIC;
    arry_buff.append(creat_region(region,item,text));


//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::xin_hong_creat_action_new()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = LINE_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 3;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = 64;
    region.hight = 16;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0x00;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    item.text_font_length = sizeof (TEXT_FONT);
    item.other_font_length = sizeof (NUM_FONT);
    item.text_font.append(TEXT_FONT);
    item.other_font.append(NUM_FONT);
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 1;
    QString text = "%start_station1%";
    item.move_type = MOVE_LEFT;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);

    region.x = 96;
    region.y = 0;
    region.width = 64;
    region.hight = SCREEN_HEIGHT;

    item.message_type = 1;
    text = "%end_station1%";
    item.move_type = MOVE_LEFT;
    arry_buff.append(creat_region(region,item,text));


    region.x = 64;
    region.y = 0;
    region.width = 32;
    region.hight = SCREEN_HEIGHT;

    item.text_color[0] = 0xff;
    item.text_color[1] = 0xff;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    item.message_type = 1;
    text = "%line_num%";
    item.move_type = MOVE_LEFT;
    arry_buff.append(creat_region(region,item,text));

//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::xin_hong_creat_action_left()
{
    uint16_t wid = 40;
    uint16_t hei = 16;
    e300_action_t action;
    action.lenght = 0;
    action.id = LEFT_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 2;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = wid;
    region.hight = hei;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0x00;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    item.text_font_length = sizeof (TEXT_FONT);
    item.other_font_length = sizeof (NUM_FONT);
    item.text_font.append(TEXT_FONT);
    item.other_font.append(NUM_FONT);
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 2;
    QString text = "left_2.bin";
    item.move_type = MOVE_LEFT_CONTINUE;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);

    region.x = SCREEN_HEIGHT;
    region.y = 0;
    region.width = SCREEN_WIDTH - wid;
    region.hight = SCREEN_HEIGHT;


    item.message_type = 1;
    text = "%line_num%";
    item.move_type = MOVE_LEFT;
    arry_buff.append(creat_region(region,item,text));

//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::xin_hong_creat_action_right()
{
    uint16_t wid = 40;
    uint16_t hei = 16;
    e300_action_t action;
    action.lenght = 0;
    action.id = RIGHT_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 2;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = SCREEN_WIDTH - wid;
    region.y = 0;
    region.width = wid;
    region.hight = hei;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0x00;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    item.text_font_length = sizeof (TEXT_FONT);
    item.other_font_length = sizeof (NUM_FONT);
    item.text_font.append(TEXT_FONT);
    item.other_font.append(NUM_FONT);
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 2;
    QString text = "right_2.bin";
    item.move_type = MOVE_RIGHT_CONTINUE;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);

    region.x = 0;
    region.y = 0;
    region.width = SCREEN_WIDTH - wid;
    region.hight = SCREEN_HEIGHT;


    item.message_type = 1;
    text = "%line_num%";
    item.move_type = MOVE_LEFT;
    arry_buff.append(creat_region(region,item,text));

//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::xin_hong_creat_action_stop()
{
    uint16_t wid = 80;
    uint16_t hei = 16;
    e300_action_t action;
    action.lenght = 0;
    action.id = STOP_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 2;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = wid;
    region.hight = hei;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0x00;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    item.text_font_length = sizeof (TEXT_FONT);
    item.other_font_length = sizeof (NUM_FONT);
    item.text_font.append(TEXT_FONT);
    item.other_font.append(NUM_FONT);
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 1;
    QString text = "%line_num%";
    item.move_type = MOVE_LEFT;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);

    region.x = wid;
    region.y = 0;
    region.width = SCREEN_WIDTH - wid;
    region.hight = SCREEN_HEIGHT;


    item.text_color[0] = 0xff;
    item.text_color[1] = 0xff;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    item.message_type = 1;
    text = "%stop_text%";
    item.move_type = MOVE_STATIC;
    arry_buff.append(creat_region(region,item,text));

    region.x = SCREEN_WIDTH - wid;
    region.y = 0;
    region.width = wid;
    region.hight = SCREEN_HEIGHT;


    item.message_type = 2;
    text = "right_2.bin";
    item.move_type = MOVE_RIGHT_CONTINUE;
    arry_buff.append(creat_region(region,item,text));


//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::xin_hong_creat_action_stop_2()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = STOP_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 3;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = 64;
    region.hight = 16;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0xff;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    QString text_font = TEXT_FONT;
    QString other_font = NUM_FONT;
    item.text_font_length = text_font.length();
    item.other_font_length = other_font.length();
    item.text_font.append(text_font.toUtf8());
    item.other_font.append(other_font.toUtf8());
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 1;
    item.id = 4;
    QString text = "刹  车";
    item.move_type = MOVE_LEFT;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);


    region.x = 96;
    region.y = 0;
    item.id = 5;
    text = "注  意";
    arry_buff.append(creat_region(region,item,text));



    region.x = 64;
    region.y = 0;
    region.width = 32;
    region.hight = SCREEN_HEIGHT;

    item.text_color[0] = 0xff;
    item.text_color[1] = 0x00;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    item.id = 6;
    text = "%line_num%";
    arry_buff.append(creat_region(region,item,text));

//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::xin_hong_creat_action_double_2()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = DOUBLE_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 2;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 20;
    region.y = 0;
    region.width = 24;
    region.hight = 16;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0xff;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    QString text_font = TEXT_FONT;
    QString other_font = NUM_FONT;
    item.text_font_length = text_font.length();
    item.other_font_length = other_font.length();
    item.text_font.append(text_font.toUtf8());
    item.other_font.append(other_font.toUtf8());
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 2;
    item.id = 11;
    QString text = "left_2.bin";
    item.move_type = MOVE_LEFT_CONTINUE;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);

    region.x = 116;
    region.y = 0;

    item.message_type = 2;
    item.id = 12;
    text = "right_2.bin";
    item.move_type = MOVE_RIGHT_CONTINUE;
    arry_buff.append(creat_region(region,item,text));

//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::xin_hong_creat_program_test()
{
    e300_program_t program;
    program.addr = xin_hong_wei_pai_addr;
    program.screen_width = SCREEN_WIDTH;
    program.screen_hight = SCREEN_HEIGHT;
    program.program_id = 2;
    program.ad_switch = 0;
    program.host_type = HOST_KAILUN;
    program.boad = 19200;
    program.line_program_x = 0;
    program.line_progtam_y = 0;
    program.line_program_width = SCREEN_WIDTH;
    program.line_program_hight = SCREEN_HEIGHT;
    for(int i=0;i<8;i++)
        program.save[i] = 0;
    program.action_cnt = 4;

    program.priority_action[0] = STOP_PROGRAM;
    program.priority_action[1] = DOUBLE_PROGRAM;
    program.priority_action[2] = LEFT_PROGRAM;
    program.priority_action[3] = RIGHT_PROGRAM;
    program.priority_action[4] = LINE_PROGRAM;
    program.priority_action[5] = HOST_AD_PROGRAM;
    program.priority_action[6] = HOST_AD_PROGRAM;
    program.priority_action[7] = HOST_AD_PROGRAM;

    QByteArray arry;
    arry.append((char*)&program, sizeof(e300_program_t));

//    arry.append(xin_hong_creat_action_wei());
//    arry.append(xin_hong_creat_action_stop());
//    arry.append(xin_hong_creat_action_left());
//    arry.append(xin_hong_creat_action_right());
//    arry.append(xin_hong_creat_action_double());
    arry.append(xin_hong_creat_action_wei_test());
    arry.append(xin_hong_creat_action_left_test());
    arry.append(xin_hong_creat_action_right_test());
    arry.append(xin_hong_creat_action_stop_test());
//    DEBUG_INFO(QString("program_length:%1").arg(arry.length()));

//    QString str = "program:";
//    foreach (quint8 ch, arry) {
//       str.append(QString("%1 ").arg(ch,2,16,QLatin1Char( '0' )));
//    }
//    DEBUG_INFO(str);

    return arry;
}

QByteArray e300_config::xin_hong_creat_action_wei_test()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = LINE_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 1;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = SCREEN_WIDTH;
    region.hight = SCREEN_HEIGHT;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0xff;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    QString text_font = TEXT_FONT;
    QString other_font = NUM_FONT;
    item.text_font_length = text_font.length();
    item.other_font_length = other_font.length();
    item.text_font.append(text_font.toUtf8());
    item.other_font.append(other_font.toUtf8());
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 2;
    item.id = 13;
    QString text = "black.bin";
    item.move_type = MOVE_LEFT_CONTINUE;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);


//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::xin_hong_creat_action_left_test()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = LEFT_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 1;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = SCREEN_WIDTH;
    region.hight = SCREEN_HEIGHT;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0xff;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    QString text_font = TEXT_FONT;
    QString other_font = NUM_FONT;
    item.text_font_length = text_font.length();
    item.other_font_length = other_font.length();
    item.text_font.append(text_font.toUtf8());
    item.other_font.append(other_font.toUtf8());
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 2;
    item.id = 14;
    QString text = "red.bin";
    item.move_type = MOVE_LEFT_CONTINUE;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);


//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::xin_hong_creat_action_right_test()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = RIGHT_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 1;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = SCREEN_WIDTH;
    region.hight = SCREEN_HEIGHT;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0xff;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    QString text_font = TEXT_FONT;
    QString other_font = NUM_FONT;
    item.text_font_length = text_font.length();
    item.other_font_length = other_font.length();
    item.text_font.append(text_font.toUtf8());
    item.other_font.append(other_font.toUtf8());
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 2;
    item.id = 15;
    QString text = "green.bin";
    item.move_type = MOVE_LEFT_CONTINUE;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);


//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::xin_hong_creat_action_stop_test()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = STOP_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 1;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = SCREEN_WIDTH;
    region.hight = SCREEN_HEIGHT;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0xff;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    QString text_font = TEXT_FONT;
    QString other_font = NUM_FONT;
    item.text_font_length = text_font.length();
    item.other_font_length = other_font.length();
    item.text_font.append(text_font.toUtf8());
    item.other_font.append(other_font.toUtf8());
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 2;
    item.id = 16;
    QString text = "blue.bin";
    item.move_type = MOVE_LEFT_CONTINUE;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);


//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::xin_hong_creat_action_double()
{
    uint16_t wid = 40;
    uint16_t hei = 16;
    e300_action_t action;
    action.lenght = 0;
    action.id = DOUBLE_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 3;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = wid;
    region.hight = hei;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0x00;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    QString text_font = TEXT_FONT;
    QString other_font = NUM_FONT;
    item.text_font_length = text_font.length();
    item.other_font_length = other_font.length();
    item.text_font.append(TEXT_FONT);
    item.other_font.append(NUM_FONT);
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 2;
    QString text = "left_2.bin";
    item.move_type = MOVE_LEFT_CONTINUE;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);

    region.x = wid;
    region.y = 0;
    region.width = SCREEN_WIDTH - wid - wid;
    region.hight = SCREEN_HEIGHT;


    item.message_type = 1;
    text = "%line_num%";
    item.move_type = MOVE_LEFT;
    arry_buff.append(creat_region(region,item,text));

    region.x = SCREEN_WIDTH - wid;
    region.y = 0;
    region.width = wid;
    region.hight = SCREEN_HEIGHT;


    item.message_type = 2;
    text = "right_2.bin";
    item.move_type = MOVE_RIGHT_CONTINUE;
    arry_buff.append(creat_region(region,item,text));


//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::xin_hong_creat_action_left_2()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = LEFT_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 2;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 20;
    region.y = 0;
    region.width = 24;
    region.hight = 16;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0xff;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    QString text_font = TEXT_FONT;
    QString other_font = NUM_FONT;
    item.text_font_length = text_font.length();
    item.other_font_length = other_font.length();
    item.text_font.append(text_font.toUtf8());
    item.other_font.append(other_font.toUtf8());
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 2;
    item.id = 7;
    QString text = "left_2.bin";
    item.move_type = MOVE_LEFT_CONTINUE;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);

    region.x = 80;
    region.y = 0;
    region.width = 80;
    region.hight = SCREEN_HEIGHT;


    item.message_type = 1;
    item.id = 8;
    text = "左  转";
    item.move_type = MOVE_LEFT;
    arry_buff.append(creat_region(region,item,text));

//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::xin_hong_creat_action_right_2()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = RIGHT_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 2;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 116;
    region.y = 0;
    region.width = 24;
    region.hight = 16;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0xff;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    QString text_font = TEXT_FONT;
    QString other_font = NUM_FONT;
    item.text_font_length = text_font.length();
    item.other_font_length = other_font.length();
    item.text_font.append(text_font.toUtf8());
    item.other_font.append(other_font.toUtf8());
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_RIGHT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 2;
    item.id = 9;
    QString text = "right_2.bin";
    item.move_type = MOVE_RIGHT_CONTINUE;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);

    region.x = 0;
    region.y = 0;
    region.width = 80;
    region.hight = SCREEN_HEIGHT;


    item.message_type = 1;
    item.id = 10;
    text = "右  转";
    item.move_type = MOVE_LEFT;
    arry_buff.append(creat_region(region,item,text));

//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

/*
 * 测路牌节目单
*/
QByteArray e300_config::xin_hong_creat_program_side()
{
    e300_program_t program;
    program.addr = xin_hong_ce_pai_addr;
    program.screen_width = SCREEN_WIDTH;
    program.screen_hight = SCREEN_HEIGHT;
    program.program_id = 2;
    program.ad_switch = 0;
    program.host_type = HOST_KAILUN;
    program.boad = 19200;
    program.line_program_x = 0;
    program.line_progtam_y = 0;
    program.line_program_width = SCREEN_WIDTH;
    program.line_program_hight = SCREEN_HEIGHT;
    for(int i=0;i<8;i++)
        program.save[i] = 0;
    program.action_cnt = 1;

    program.priority_action[0] = STOP_PROGRAM;
    program.priority_action[1] = DOUBLE_PROGRAM;
    program.priority_action[2] = LEFT_PROGRAM;
    program.priority_action[3] = RIGHT_PROGRAM;
    program.priority_action[4] = LINE_PROGRAM;
    program.priority_action[5] = NO_WORK_PROGRAM;
    program.priority_action[6] = HOST_AD_PROGRAM;
    program.priority_action[7] = HOST_AD_PROGRAM;

    QByteArray arry;
    arry.append((char*)&program, sizeof(e300_program_t));

    arry.append(xin_hong_creat_action_256x64_2());
//    arry.append(xin_hong_creat_action_side_2());
//    arry.append(xin_hong_creat_action_noWork());
//    arry.append(xin_hong_creat_action_stop());
//    arry.append(xin_hong_creat_action_left());
//    arry.append(xin_hong_creat_action_right());
//    arry.append(creat_action_double());
//    DEBUG_INFO(QString("program_length:%1").arg(arry.length()));

//    QString str = "program:";
//    foreach (quint8 ch, arry) {
//       str.append(QString("%1 ").arg(ch,2,16,QLatin1Char( '0' )));
//    }
//    DEBUG_INFO(str);

    return arry;
}

QByteArray e300_config::xin_hong_creat_action_256x64()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = LINE_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 2;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = SCREEN_WIDTH;
    region.hight = SCREEN_HEIGHT;
    region.type = 1;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 3;//内部region个数


    e300_inside_region_t inside_region;//内部区域
    inside_region.min_width = 0;
    inside_region.max_width = 60;
    for(int i =0;i<8;i++)
    {
        inside_region.save[i] = 0;
    }
    inside_region.item_cnt = 1;//内部region中item个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0xff;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    QString text_font = TEXT_FONT;
    QString other_font = NUM_FONT;
    item.text_font_length = text_font.length();
    item.other_font_length = other_font.length();
    item.text_font.append(text_font.toUtf8());
    item.other_font.append(other_font.toUtf8());
    item.bold = 0;
    item.text_size = 32;
    item.other_size = 32;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_left;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
    item.id = 1;
    QString text = "%line_num%";

    QByteArray arry_buff = creat_inside_region(inside_region,item,text);

    QString str = "arry_buff";
    foreach (quint8 ch, arry_buff) {
       str.append(QString("%1 ").arg(ch,2,16,QLatin1Char( '0' )));
    }
    DEBUG_INFO(str);
//    QByteArray arry_buff;

    inside_region.min_width = 64;
    inside_region.max_width = 64;


    item.id = 2;
    item.message_type = 2;
    text = "right.bin";
    item.move_type = MOVE_RIGHT_CONTINUE;
    arry_buff.append(creat_inside_region(inside_region,item,text));

    item.text_color[0] = 0xff;
    item.text_color[1] = 0xFF;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    inside_region.min_width = 0;
    inside_region.max_width = SCREEN_WIDTH;
    item.message_type = 1;
    item.id = 3;
    text = "%end_station1%";
    item.move_type = MOVE_LEFT;
    arry_buff.append(creat_inside_region(inside_region,item,text));

    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + region.length + 2;
    arry.append((char*)&action, sizeof(action));
    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);



//    region.x = 0;
//    region.y = 32;
//    region.width = 256;
//    region.hight = 32;
//    region.type = 0;
//    for(int i =0;i<8;i++)
//    {
//        region.save[i] = 0;
//    }
//    region.region_cnt = 1;//内部region个数

//    item.effect = 18;
//    item.exit = 1;
//    item.message_type = 1;
//    item.x_move = 0;
//    item.text_color[0] = 0xff;
//    item.text_color[1] = 0x00;
//    item.text_color[2] = 0x00;
//    item.backcolor[0] = 0x00;
//    item.backcolor[1] = 0x00;
//    item.backcolor[2] = 0x00;


//    item.text_font_length = text_font.length();
//    item.other_font_length = other_font.length();
//    item.text_font.append(text_font.toUtf8());
//    item.other_font.append(other_font.toUtf8());
//    item.bold = 0;
//    item.text_size = SCREEN_HEIGHT;
//    item.other_size = SCREEN_HEIGHT;
//    item.play_time = 0;
//    item.speed = 24;
//    item.font_gap = 0;
//    item.shui_ping_type = shui_ping_mid;
//    item.chui_zhi_type = chui_zhi_mid;
//    item.move_type = MOVE_LEFT;
//    for(int i =0;i<8;i++)
//    {
//        item.save[i] = 0;
//    }
////    QByteArray arry_buff;


//    item.message_type = 1;
//    item.id = 4;
//    text = "前门上车";
//    item.move_type = MOVE_LEFT;
////    QByteArray arry_buff;
//    arry_buff = creat_region(region,item,text);

//    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
//    arry.append((char*)&action, sizeof(action));
////    arry.append((char*)&region, sizeof(region));
//    arry.append( arry_buff);

    return arry;
}

QByteArray e300_config::xin_hong_creat_action_256x64_2()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = LINE_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 6;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = 64;
    region.hight = 32;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xb5;
    item.text_color[1] = 0x00;
    item.text_color[2] = 0xff;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;


    QString text_font = TEXT_FONT;
    QString other_font = NUM_FONT;
    item.text_font_length = text_font.length();
    item.other_font_length = other_font.length();
    item.text_font.append(text_font.toUtf8());
    item.other_font.append(other_font.toUtf8());
    item.bold = 0;
    item.text_size = 32;
    item.other_size = 32;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 1;
    item.id = 1;
    QString text = "%line_num%";
    item.move_type = MOVE_LEFT;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);



    item.text_color[0] = 0xff;
    item.text_color[1] = 0x97;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    region.x = 64;
    region.y = 0;
    region.width = 64;
    region.hight = 32;
    item.id = 2;
    text = "开往";
    item.move_type = MOVE_STATIC;
    arry_buff.append(creat_region(region,item,text));

//    region.x = 64;
//    region.y = 0;
//    region.width = 32;
//    region.hight = 32;
//    item.message_type = 2;
//    item.id = 9;
//    text = "right_32x32.bin";
//    item.move_type = MOVE_STATIC;
////    QByteArray arry_buff;
//    arry_buff.append(creat_region(region,item,text));



    item.text_color[0] = 0xff;
    item.text_color[1] = 0x00;
    item.text_color[2] = 0x59;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    region.x = 128;
    region.y = 0;
    region.width = 128;
    region.hight = 32;
    item.id = 3;
    text = "%end_station1%";
    item.move_type = MOVE_STATIC;
    arry_buff.append(creat_region(region,item,text));



//    text_font = "arial16.font";
//    other_font = "coll16.font";
//    item.text_font_length = text_font.length();
//    item.other_font_length = other_font.length();
//    item.text_font = text_font.toUtf8();
//    item.other_font = other_font.toUtf8();
    item.text_color[0] = 0x00;
    item.text_color[1] = 0xe4;
    item.text_color[2] = 0xff;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    item.text_size = 32;
    item.other_size = 32;
    region.x = 128;
    region.y = 32;
    region.width = 128;
    region.hight = 32;
    item.id = 4;
    text = "票价2元";
    item.move_type = MOVE_STATIC;
    arry_buff.append(creat_region(region,item,text));



        text_font = "arial16.font";
        other_font = "coll16.font";
        item.text_font_length = text_font.length();
        item.other_font_length = other_font.length();
        item.text_font = text_font.toUtf8();
        item.other_font = other_font.toUtf8();
        item.text_color[0] = 0x1d;
        item.text_color[1] = 0xff;
        item.text_color[2] = 0x00;
        item.backcolor[0] = 0x00;
        item.backcolor[1] = 0x00;
        item.backcolor[2] = 0x00;
        item.text_size = 16;
        item.other_size = 16;
        region.x = 14;
        region.y = 32;
        region.width = 58;
        region.hight = 16;
        item.id = 5;
        text = "前门上";
        item.move_type = MOVE_STATIC;
        arry_buff.append(creat_region(region,item,text));

        item.text_color[0] = 0xa3;
        item.text_color[1] = 0x00;
        item.text_color[2] = 0xff;
        item.backcolor[0] = 0x00;
        item.backcolor[1] = 0x00;
        item.backcolor[2] = 0x00;
        item.text_size = 16;
        item.other_size = 16;
        region.x = 56;
        region.y = 48;
        region.width = 58;
        region.hight = 16;
        item.id = 6;
        text = "后门下";
        item.move_type = MOVE_STATIC;
        arry_buff.append(creat_region(region,item,text));



//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::xin_hong_creat_action_side()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = LINE_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 1;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = SCREEN_WIDTH;
    region.hight = SCREEN_HEIGHT;
    region.type = 1;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 3;//内部region个数


    e300_inside_region_t inside_region;//内部区域
    inside_region.min_width = 0;
    inside_region.max_width = 60;
    for(int i =0;i<8;i++)
    {
        inside_region.save[i] = 0;
    }
    inside_region.item_cnt = 1;//内部region中item个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0xff;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    QString text_font = TEXT_FONT;
    QString other_font = NUM_FONT;
    item.text_font_length = text_font.length();
    item.other_font_length = other_font.length();
    item.text_font.append(text_font.toUtf8());
    item.other_font.append(other_font.toUtf8());
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_left;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
    item.id = 1;
    QString text = "%line_num%";

    QByteArray arry_buff = creat_inside_region(inside_region,item,text);

    QString str = "arry_buff";
    foreach (quint8 ch, arry_buff) {
       str.append(QString("%1 ").arg(ch,2,16,QLatin1Char( '0' )));
    }
    DEBUG_INFO(str);
//    QByteArray arry_buff;

    inside_region.min_width = SCREEN_HEIGHT;
    inside_region.max_width = SCREEN_HEIGHT;


    item.message_type = 2;
    text = "right.bin";
    item.move_type = MOVE_RIGHT_CONTINUE;
    arry_buff.append(creat_inside_region(inside_region,item,text));

    item.text_color[0] = 0xff;
    item.text_color[1] = 0xFF;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    inside_region.min_width = 0;
    inside_region.max_width = SCREEN_WIDTH;
    item.message_type = 1;
    item.id = 2;
    text = "%end_station1%";
    item.move_type = MOVE_LEFT;
    arry_buff.append(creat_inside_region(inside_region,item,text));

    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + region.length + 2;
    arry.append((char*)&action, sizeof(action));
    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

/*
 * 静态区域 线路+“开往 终点”
 * 区域宽度 128x16
 * 区域占字   3+5
*/
QByteArray e300_config::xin_hong_creat_action_side_2()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = LINE_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 2;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = 48;
    region.hight = 16;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0x00;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;


    QString text_font = TEXT_FONT;
    QString other_font = NUM_FONT;
    item.text_font_length = text_font.length();
    item.other_font_length = other_font.length();
    item.text_font.append(text_font.toUtf8());
    item.other_font.append(other_font.toUtf8());
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 1;
    item.id = 1;
    QString text = "%line_num%";
    item.move_type = MOVE_LEFT;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);

    region.x = 48;
    region.y = 0;
    region.width = SCREEN_WIDTH - 48;
    region.hight = SCREEN_HEIGHT;


    item.text_color[0] = 0xff;
    item.text_color[1] = 0xff;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    item.message_type = 1;
    item.id = 2;
    text = "开往 %end_station1%";
    item.move_type = MOVE_STATIC;
    arry_buff.append(creat_region(region,item,text));


//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::xin_hong_creat_action_noWork()
{
    e300_action_t action;
    action.lenght = 0;
    action.id = NO_WORK_PROGRAM;
    action.show_type = 0;
    for(int i =0;i<8;i++)
    {
        action.save[i] = 0;
    }
    action.region_cnt = 1;//外部region个数


    QByteArray arry;
    e300_region_t region;
    region.x = 0;
    region.y = 0;
    region.width = SCREEN_WIDTH;
    region.hight = SCREEN_HEIGHT;
    region.type = 0;
    for(int i =0;i<8;i++)
    {
        region.save[i] = 0;
    }
    region.region_cnt = 1;//内部region个数

    e300_item_t item;
    item.effect = 18;
    item.exit = 1;
    item.message_type = 1;
    item.x_move = 0;
    item.text_color[0] = 0xff;
    item.text_color[1] = 0x00;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;


    QString text_font = TEXT_FONT;
    QString other_font = NUM_FONT;
    item.text_font_length = text_font.length();
    item.other_font_length = other_font.length();
    item.text_font.append(text_font.toUtf8());
    item.other_font.append(other_font.toUtf8());
    item.bold = 0;
    item.text_size = SCREEN_HEIGHT;
    item.other_size = SCREEN_HEIGHT;
    item.play_time = 0;
    item.speed = 24;
    item.font_gap = 0;
    item.shui_ping_type = shui_ping_mid;
    item.chui_zhi_type = chui_zhi_mid;
    item.move_type = MOVE_LEFT;
    for(int i =0;i<8;i++)
    {
        item.save[i] = 0;
    }
//    QByteArray arry_buff;


    item.message_type = 1;
    item.id = 1;
    QString text = "%line_num%";
    item.move_type = MOVE_LEFT;
//    QByteArray arry_buff;
    QByteArray arry_buff = creat_region(region,item,text);

    region.x = 48;
    region.y = 0;
    region.width = SCREEN_WIDTH - 48;
    region.hight = SCREEN_HEIGHT;


    item.text_color[0] = 0xff;
    item.text_color[1] = 0xff;
    item.text_color[2] = 0x00;
    item.backcolor[0] = 0x00;
    item.backcolor[1] = 0x00;
    item.backcolor[2] = 0x00;
    item.message_type = 1;
    item.id = 2;
    text = "开往 %end_station1%";
    item.move_type = MOVE_STATIC;
//    arry_buff.append(creat_region(region,item,text));


//    region.length = sizeof (e300_region_t) -2 + arry_buff.length();
    action.lenght = sizeof(e300_action_t) - 2 + arry_buff.length();
    arry.append((char*)&action, sizeof(action));
//    arry.append((char*)&region, sizeof(region));
    arry.append( arry_buff);
    return arry;
}

QByteArray e300_config::xin_hong_creat_program_wei()
{
    e300_program_t program;
    program.addr = xin_hong_wei_pai_addr;
    program.screen_width = SCREEN_WIDTH;
    program.screen_hight = SCREEN_HEIGHT;
    program.program_id = 2;
    program.ad_switch = 0;
    program.host_type = HOST_KAILUN;
    program.boad = 19200;
    program.line_program_x = 0;
    program.line_progtam_y = 0;
    program.line_program_width = SCREEN_WIDTH;
    program.line_program_hight = SCREEN_HEIGHT;
    for(int i=0;i<8;i++)
        program.save[i] = 0;
    program.action_cnt = 6;

    program.priority_action[0] = STOP_PROGRAM;
    program.priority_action[1] = DOUBLE_PROGRAM;
    program.priority_action[2] = LEFT_PROGRAM;
    program.priority_action[3] = RIGHT_PROGRAM;
    program.priority_action[4] = LINE_PROGRAM;
    program.priority_action[5] = NO_WORK_PROGRAM;
    program.priority_action[6] = HOST_AD_PROGRAM;
    program.priority_action[7] = HOST_AD_PROGRAM;

    QByteArray arry;
    arry.append((char*)&program, sizeof(e300_program_t));

//    arry.append(xin_hong_creat_action_wei());
//    arry.append(xin_hong_creat_action_stop());
//    arry.append(xin_hong_creat_action_left());
//    arry.append(xin_hong_creat_action_right());
//    arry.append(xin_hong_creat_action_double());
    arry.append(xin_hong_creat_action_2());
    arry.append(xin_hong_creat_action_stop_2());
    arry.append(xin_hong_creat_action_left_2());
    arry.append(xin_hong_creat_action_right_2());
    arry.append(xin_hong_creat_action_double_2());
    arry.append(xin_hong_creat_action_noWork());
//    DEBUG_INFO(QString("program_length:%1").arg(arry.length()));

//    QString str = "program:";
//    foreach (quint8 ch, arry) {
//       str.append(QString("%1 ").arg(ch,2,16,QLatin1Char( '0' )));
//    }
//    DEBUG_INFO(str);

    return arry;
}

QByteArray e300_config::xin_hong_creat_action_wei()
{
// return xin_hong_creat_action();
    return  xin_hong_creat_action_2();
}

